<?php

namespace app\common\controller;

use app\common\controller\lib\Common;
use app\common\controller\lib\EntranceToken as ET;
use cmf\controller\HomeBaseController;
use think\Request;

/**

 *用户控制器202004201030

 */

class UserController extends HomeBaseController
{

    protected $common; //操作实例

    protected function _initialize()
    {

        $action = $this->request->action();

        $NOTLOGINACTION = ['activation'];

        $id = get_current_admin_id();

        if (!in_array($action, $NOTLOGINACTION) && empty($id)) {

            return zy_json_echo(false, '非法登录！', null, 100, '/login');

        }

        $this->common = new Common();

    }

    /**

     *新用户注册激活

     */

    public function activation()
    {

        $data = [

            'token' => ET::getToken(),

            'param' => [

                'type' => '1020042101',

            ],

        ];

        $res = $this->common->requestInterface(ET::getUrl(), $data);

        return $res;

    }

    /**

     *修改密码

     */

    public function modify($old, $new)
    {

        $data = [

            'token' => ET::getToken(),

            'param' => [

                'type' => '1020042101',

                'old'  => $old,

                'new'  => $new,

            ],

        ];

        $res = $this->common->requestInterface(ET::getUrl(), $data);

        return $res;

    }

}
